package com.xlh.common;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * 返回结果枚举类
 *
 * @author cheer
 */
public enum ResultEnum {

    SUCCESS(200, "请求成功"),

    // 通用异常
    BAD_REQUEST(400, "参数不合法"),
    UNAUTHORIZED(401, "用户未登录或已超时"),
    FORBIDDEN(403, "用户没有执行该请求的权限"),
    NOT_FOUND(404, "内容不存在"),
    SERVER_ERROR(500, "服务器内部错误"),
    // 用户模块
    LOGIN_FAILED(100100, "登录失败"),
    USER_INFO_MATCH_FAILED(100101, "用户名或密码错误"),
    VERIFICATION_CODE_ERROR(100102, "图形验证码错误"),
    ACCOUNT_NOT_EXIST(100103, "账号不存在"),
    ACCOUNT_EXPIRED(100104, "账号已过期"),
    USER_EXIST(100105, "用户已存在"),
    SMS_CODE_ERROR(100107, "短信验证码错误"),
    SMS_CODE_SEND_FAIL_ERROR(100108, "短信验证码发送频繁，请于%s分钟后重试");

    private Integer code;

    private String message;

    ResultEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("code", code)
                .append("message", message)
                .toString();
    }
}
